package com.dimples.common.entity;

import com.dimples.common.constant.StrPool;
import com.dimples.common.enums.LoginType;

import java.util.List;
import java.util.Set;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2021/6/26
 */
@Data
public class SecurityUser {

    private LoginType loginType;

    private String remoteAddress;

    private String theme;

    private String avatar;

    private Long userId;

    private Long deptId;

    private String email;

    private String mobile;

    private String ssex;

    private String loginTime;

    private String username;

    private String realName;

    private Set<String> authorities;

    private List<String> roleCodes;

    private boolean accountNonExpired;

    private boolean accountNonLocked;

    private boolean credentialsNonExpired;

    private boolean enabled;

    private String deptName;

    private LoginDetails loginDetails = new LoginDetails();

    /**
     * 过期时间
     */
    private String expireTime;

    private String perms;

    public void setAuthorities(Set<String> authorities) {
        this.authorities = authorities;
        this.perms = StrUtil.join(StrPool.COMMA, authorities);
    }

    public SecurityUser() {
        this.accountNonExpired = true;
        this.accountNonLocked = true;
        this.credentialsNonExpired = true;
        this.enabled = true;
    }
}
